package lxy;

public class Workt7 {

    public static void t1(){
        StringBuffer s = new StringBuffer();
        s.append("woaijavahajajavavahajavaaiwo");
        int f = 0;
        int num = 0;
        while ((f = s.indexOf("java")) != -1){
            s.delete(f,f+4);
            num++;
        }
        System.out.println(s);
        System.out.println(num);
    }

    public static void t2(){
        String str = "woaijavahajajavavahajavaaiwo";
        int num = 0;
        int index = 0;
        String s = "java";
        while (true){
            if ((index = str.indexOf(s)) == -1){
                break;
            }
            str = str.substring(0, index) + str.substring(index+s.length(), str.length());
            num++;
        }
        System.out.println(str);
        System.out.println(num);
    }
    public static void main(String[] args) {
        t1();
        t2();
    }
}
